home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / Framewrk / FWViews / FWCntrHW.h < prev    next >
Encoding:
Text File  |  1996-09-17  |  11.0 KB  |  355 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWCntrHW.h
  4. //    Release Version:    $ ODF 2 $
  5. //
  6. //    Copyright:            (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #if    defined(FW_BUILD_WIN) && !defined(FWCNTRHW_H)
  11. #define FWCNTRHW_H
  12.  
  13. #ifndef FWODTYPS_H
  14. #include "FWODTyps.h"
  15. #endif
  16.  
  17. // ----- Foundation Includes -----
  18.  
  19. #ifndef FWRUNTYP_H
  20. #include "FWRunTyp.h"
  21. #endif
  22.  
  23. // ----- Platform Includes -----
  24.  
  25. #include <windows.h>
  26.  
  27. //========================================================================================
  28. // Forward declarations
  29. //========================================================================================
  30.  
  31. class FW_CControl;
  32. class FW_CScrollBar;
  33. class FW_CButton;
  34. class FW_CPushButton;
  35. class FW_CRadioButton;
  36. class FW_CRadioCluster;
  37. class FW_CPlatformPoint;
  38. class FW_CString;
  39.  
  40. //========================================================================================
  41. // Global declarations
  42. //========================================================================================
  43.  
  44. extern WORD WM_ODFGETOBJECT;
  45.  
  46. //========================================================================================
  47. // CLASS FW_SPrivWinSuperClassInfo
  48. //========================================================================================
  49.  
  50. struct FW_SPrivWinSuperClassInfo
  51. {
  52.     LPCSTR    fClassName;
  53.     LPCSTR    fOldClassName;
  54.     WNDPROC    fWndProc;
  55.     WNDPROC    fOldWndProc;
  56.     WORD    fWndExtraBytes;
  57. };
  58.  
  59. //========================================================================================
  60. // CLASS FW_CPrivWinControlHelper
  61. //========================================================================================
  62.  
  63. class FW_CPrivWinControlHelper
  64. {
  65. public:
  66.     FW_DECLARE_CLASS
  67.  
  68. //----------------------------------------------------------------------------------------
  69. // Initialization/destruction
  70. //
  71. public:
  72.     FW_CPrivWinControlHelper(Environment* ev, const FW_CClassInfo& classInfo, FW_CControl* control);
  73.     virtual ~FW_CPrivWinControlHelper();
  74.     
  75.     void                CheckForInitialize(Environment* ev, const FW_CClassInfo& classInfo);
  76.     virtual void        Initialize(Environment* ev);
  77.  
  78. //----------------------------------------------------------------------------------------
  79. // Window manipulation
  80. //
  81. public:
  82.     static FW_CPrivWinControlHelper* HWNDToHelper(HWND hWnd);
  83.  
  84.     void                Move(const FW_CPlatformPoint& location,
  85.                              const FW_CPlatformPoint& size);
  86.                              
  87.     void                SetText(const FW_CString& text);
  88.     void                GetText(FW_CString& text) const;
  89.     
  90. protected:
  91.     FW_Boolean            RegisterSuperClass(FW_SPrivWinSuperClassInfo& superClassInfo);
  92.     virtual FW_SPrivWinSuperClassInfo&
  93.                         GetSuperClassInfo() const = 0;
  94.     virtual HWND        CreateHWnd(HWND parent,
  95.                                    const FW_CPlatformPoint& location,
  96.                                    const FW_CPlatformPoint& size) = 0;
  97.  
  98. //----------------------------------------------------------------------------------------
  99. // Accessors
  100. //
  101. public:
  102.     FW_CControl*            GetControl() const;
  103.  
  104. protected:
  105.     FW_CControl*    fControl;
  106.     HWND            fHWnd;
  107. };
  108.  
  109. //----------------------------------------------------------------------------------------
  110. // FW_CPrivWinControlHelper::GetControl
  111. //----------------------------------------------------------------------------------------
  112.  
  113. inline FW_CControl* FW_CPrivWinControlHelper::GetControl() const
  114. {
  115.     return fControl;
  116. }
  117.  
  118. //========================================================================================
  119. // CLASS FW_CPrivWinScrollBarHelper
  120. //========================================================================================
  121.  
  122. class FW_CPrivWinScrollBarHelper : public FW_CPrivWinControlHelper
  123. {
  124. public:
  125.     FW_DECLARE_CLASS
  126.  
  127. //----------------------------------------------------------------------------------------
  128. // Initialization/destruction
  129. //
  130. public:
  131.     FW_CPrivWinScrollBarHelper(Environment* ev, const FW_CClassInfo& classInfo, FW_CScrollBar* scrollBar);
  132.     virtual ~FW_CPrivWinScrollBarHelper();
  133.  
  134.     virtual void        Initialize(Environment* ev);
  135.  
  136. //----------------------------------------------------------------------------------------
  137. // Scrolling
  138. //
  139. public:
  140.     void                HandleScrollMessage(WORD sbCode, WORD currentPosition);
  141.  
  142. //----------------------------------------------------------------------------------------
  143. // Window manipulation
  144. //
  145.  
  146. protected:
  147.     virtual FW_SPrivWinSuperClassInfo& GetSuperClassInfo() const;
  148.     virtual HWND        CreateHWnd(HWND parent,
  149.                                    const FW_CPlatformPoint& location,
  150.                                    const FW_CPlatformPoint& size);
  151.  
  152. //----------------------------------------------------------------------------------------
  153. // Windows message handling
  154. //
  155. public:
  156.     static LRESULT CALLBACK    WindowProc(HWND hWnd, UINT msg,
  157.                                        WPARAM wParam, LPARAM lParam);
  158.  
  159. //----------------------------------------------------------------------------------------
  160. // Windows scroll bar attribute accessors
  161. //
  162. public:
  163.     int GetScrollPos() const;
  164.     void SetScrollPos(int position);
  165.     
  166.     void GetScrollRange(int& minPosition, int& maxPosition) const;
  167.     void SetScrollRange(int minPosition, int maxPosition);
  168.     
  169. private:
  170.     static FW_SPrivWinSuperClassInfo fgSuperClassInfo;
  171. };
  172.  
  173. //----------------------------------------------------------------------------------------
  174. // FW_CPrivWinScrollBarHelper::GetScrollPos
  175. //----------------------------------------------------------------------------------------
  176.  
  177. inline int FW_CPrivWinScrollBarHelper::GetScrollPos() const
  178. {
  179.     return fHWnd ? ::GetScrollPos(fHWnd, SB_CTL) : 0;
  180. }
  181.  
  182. //----------------------------------------------------------------------------------------
  183. // FW_CPrivWinScrollBarHelper::SetScrollPos
  184. //----------------------------------------------------------------------------------------
  185.  
  186. inline void FW_CPrivWinScrollBarHelper::SetScrollPos(int position)
  187. {
  188.     if (fHWnd)
  189.         ::SetScrollPos(fHWnd, SB_CTL, position, TRUE);
  190. }
  191.  
  192. //----------------------------------------------------------------------------------------
  193. // FW_CPrivWinScrollBarHelper::GetScrollRange
  194. //----------------------------------------------------------------------------------------
  195.  
  196. inline void FW_CPrivWinScrollBarHelper::GetScrollRange(int& minPosition,
  197.                                                        int& maxPosition) const
  198. {
  199.     if (fHWnd)
  200.         ::GetScrollRange(fHWnd, SB_CTL, &minPosition, &maxPosition);
  201. }
  202.  
  203. //----------------------------------------------------------------------------------------
  204. // FW_CPrivWinScrollBarHelper::SetScrollRange
  205. //----------------------------------------------------------------------------------------
  206.  
  207. inline void FW_CPrivWinScrollBarHelper::SetScrollRange(int minPosition, int maxPosition)
  208. {
  209.     if (fHWnd)
  210.         ::SetScrollRange(fHWnd, SB_CTL, minPosition, maxPosition, TRUE);
  211. }
  212.  
  213. //========================================================================================
  214. // CLASS FW_CPrivWinButtonHelper
  215. //========================================================================================
  216.  
  217. class FW_CPrivWinButtonHelper : public FW_CPrivWinControlHelper
  218. {
  219. public:
  220.     FW_DECLARE_CLASS
  221.  
  222. //----------------------------------------------------------------------------------------
  223. // Initialization/destruction
  224. //
  225. public:
  226.     FW_CPrivWinButtonHelper(Environment* ev, const FW_CClassInfo& classInfo, FW_CButton* button);
  227.     virtual ~FW_CPrivWinButtonHelper();
  228.     
  229. //----------------------------------------------------------------------------------------
  230. // Window manipulation
  231. //
  232.  
  233. protected:
  234.     virtual FW_SPrivWinSuperClassInfo& GetSuperClassInfo() const;
  235.     static LRESULT CALLBACK    WindowProc(HWND hWnd, UINT msg,
  236.                                        WPARAM wParam, LPARAM lParam);
  237.  
  238. public:
  239.     LRESULT GetState() const;
  240.     void SetState(WPARAM state);
  241.     
  242. //----------------------------------------------------------------------------------------
  243. // Windows message handling
  244. //
  245. public:
  246.     virtual void        HandleButtonMessage() = 0;
  247.     
  248. private:
  249.     static FW_SPrivWinSuperClassInfo fgSuperClassInfo;
  250. };
  251.  
  252. //----------------------------------------------------------------------------------------
  253. // FW_CPrivWinButtonHelper::GetState
  254. //----------------------------------------------------------------------------------------
  255.  
  256. inline LRESULT FW_CPrivWinButtonHelper::GetState() const
  257. {
  258.     return ::SendMessage(fHWnd, BM_GETSTATE, 0, 0L);
  259. }
  260.  
  261. //----------------------------------------------------------------------------------------
  262. // FW_CPrivWinButtonHelper::SetState
  263. //----------------------------------------------------------------------------------------
  264.  
  265. inline void FW_CPrivWinButtonHelper::SetState(WPARAM state)
  266. {
  267.     ::SendMessage(fHWnd, BM_SETCHECK, 0, 0L);
  268. }
  269.  
  270. //========================================================================================
  271. // CLASS FW_CPrivWinPushButtonHelper
  272. //========================================================================================
  273.  
  274. class FW_CPrivWinPushButtonHelper : public FW_CPrivWinButtonHelper
  275. {
  276. public:
  277.     FW_DECLARE_CLASS
  278.  
  279. //----------------------------------------------------------------------------------------
  280. // Initialization/destruction
  281. //
  282. public:
  283.     FW_CPrivWinPushButtonHelper(Environment* ev, const FW_CClassInfo& classInfo, FW_CPushButton* button);
  284.     virtual ~FW_CPrivWinPushButtonHelper();
  285.  
  286.     virtual HWND        CreateHWnd(HWND parent,
  287.                                    const FW_CPlatformPoint& location,
  288.                                    const FW_CPlatformPoint& size);
  289.  
  290.     void                MakeDefaultButton(FW_Boolean isDefault);
  291.     
  292.  
  293. //----------------------------------------------------------------------------------------
  294. // Windows message handling
  295. //
  296. public:
  297.     virtual void            HandleButtonMessage();
  298. };
  299.  
  300. //========================================================================================
  301. // CLASS FW_CPrivWinRadioButtonHelper
  302. //========================================================================================
  303.  
  304. class FW_CPrivWinRadioButtonHelper : public FW_CPrivWinButtonHelper
  305. {
  306. public:
  307.     FW_DECLARE_CLASS
  308.  
  309. //----------------------------------------------------------------------------------------
  310. // Initialization/destruction
  311. //
  312. public:
  313.     FW_CPrivWinRadioButtonHelper(Environment* ev, const FW_CClassInfo& classInfo, FW_CRadioButton* button);
  314.     virtual ~FW_CPrivWinRadioButtonHelper();
  315.  
  316.     virtual HWND        CreateHWnd(HWND parent,
  317.                                    const FW_CPlatformPoint& location,
  318.                                    const FW_CPlatformPoint& size);
  319.  
  320. //----------------------------------------------------------------------------------------
  321. // Windows message handling
  322. //
  323. public:
  324.     virtual void            HandleButtonMessage();
  325. };
  326.  
  327. //========================================================================================
  328. // CLASS FW_CPrivWinRadioClusterHelper
  329. //========================================================================================
  330.  
  331. class FW_CPrivWinRadioClusterHelper : public FW_CPrivWinButtonHelper
  332. {
  333. public:
  334.     FW_DECLARE_CLASS
  335.  
  336. //----------------------------------------------------------------------------------------
  337. // Initialization/destruction
  338. //
  339. public:
  340.     FW_CPrivWinRadioClusterHelper(Environment* ev, const FW_CClassInfo& classInfo, FW_CRadioButton* button);
  341.     virtual ~FW_CPrivWinRadioClusterHelper();
  342.  
  343.     virtual HWND        CreateHWnd(HWND parent,
  344.                                    const FW_CPlatformPoint& location,
  345.                                    const FW_CPlatformPoint& size);
  346.  
  347. //----------------------------------------------------------------------------------------
  348. // Windows message handling
  349. //
  350. public:
  351.     virtual void            HandleButtonMessage();
  352. };
  353.  
  354. #endif
  355.